package com.yinp.proapp.fragment.bottompage;

import android.view.LayoutInflater;
import android.view.View;

import androidx.viewbinding.ViewBinding;

import com.yinp.proapp.R;
import com.yinp.proapp.base.fragment.PresenterBaseFragment;
import com.yinp.proapp.base.fragment.PresenterWanAndroidFragment;
import com.yinp.proapp.databinding.FragmentStudyBinding;
import com.yinp.proapp.databinding.ItemTwoSelectBinding;
import com.yinp.proapp.manger.StudyManager;
import com.yinp.proapp.module.customview.activity.CustomViewActivity;
import com.yinp.proapp.module.im.activity.ImActivity;
import com.yinp.proapp.module.study.activity.StudySummarizeActivity;
import com.yinp.proapp.module.study.jiguangloginshare.activity.JiGuangLoginActivity;
import com.yinp.proapp.module.study.jiguangloginshare.activity.JiGuangShareActivity;
import com.yinp.proapp.module.study.jiguangloginshare.view.TwoSelectView;
import com.yinp.proapp.module.wanandroid.activity.WandroidActivity;
import com.yinp.proapp.module.work.activity.MyWorkActivity;
import com.yinp.tools.fragment_dialog.BaseDialogFragment;
import com.yinp.tools.fragment_dialog.CommonDialogFragment;
import com.yinp.tools.fragment_dialog.DialogFragmentHolder;
import com.yinp.tools.fragment_dialog.ViewConvertListener;

/**
 * 学习的位置f
 */
public class StudyFragment extends PresenterWanAndroidFragment<FragmentStudyBinding> {
    @Override
    protected void initViews(View view) {
        initClick(this, bd.stvOne, bd.stvTwo, bd.stvThree, bd.stvFour, bd.stvFive, bd.stvSix);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        if (v == bd.stvOne) {//玩Android
            goToActivity(WandroidActivity.class);
        } else if (v == bd.stvTwo) {//学习内容总结
            goToActivity(StudySummarizeActivity.class);
        } else if (v == bd.stvThree) {//视频

        } else if (v == bd.stvFour) {//自定义view
            goToActivity(CustomViewActivity.class);
        } else if (v == bd.stvFive) {
            goToActivity(MyWorkActivity.class);
        } else if (v == bd.stvSix) {
            goToActivity(ImActivity.class);
//            initTwoSelect();
        }
    }

    private CommonDialogFragment mDialogFragment;

    private void initTwoSelect() {
        CommonDialogFragment.newInstance().setLayout(ItemTwoSelectBinding.inflate(LayoutInflater.from(getContext()), null, false))
                .setViewConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(DialogFragmentHolder holder, BaseDialogFragment dialogFragment, ViewBinding viewBinding) {
                        mDialogFragment = (CommonDialogFragment) dialogFragment;
                        ItemTwoSelectBinding binding = (ItemTwoSelectBinding) viewBinding;
                        binding.tsvSelect.setcLickListener(new TwoSelectView.CLickListener() {
                            @Override
                            public void click(boolean isLeft) {
                                if (isLeft) {
                                    goToActivity(JiGuangLoginActivity.class);
                                } else {
                                    goToActivity(JiGuangShareActivity.class);
                                }
                            }
                        });

                    }
                }).setAnimStyle(R.style.CenterDialogAnimation).setGravity(BaseDialogFragment.CENTER).setPercent(false, false).show(getFragmentManager());
    }

    @Override
    public void onPause() {
        super.onPause();
        if (mDialogFragment != null) {
            mDialogFragment.dismiss();
            mDialogFragment = null;
        }
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
    }

}
